const express = require('express');

const app = express();

// 路由器           express.Router()创建一个路由器
const userRouter = express.Router();
// 创建一个goodsRouter
const goodsRouter = express.Router();

// 用户列表   GET  /userlist
// 添加用户   GET  /useradd
// 删除用户   GET  /userdelete
userRouter.get('/userlist',(request,response)=>{
    response.send('<h1>用户列表页</h1>');
})
userRouter.get('/useradd',(request,response)=>{
    response.send('<h1>添加用户页</h1>');
})
userRouter.get('/userdelete',(request,response)=>{
    response.send('<h1>用户删除页</h1>');
})
// 商品列表   GET  /goodslist
// 添加商品   GET  /goodsadd
// 商品详情   GET  /goodsdetail
goodsRouter.get('/goodslist',(request,response)=>{
    response.send('<h1>商品列表页</h1>');
})
goodsRouter.get('/goodsadd',(request,response)=>{
    response.send('<h1>添加商品页</h1>');
})
goodsRouter.get('/goodsdetail',(request,response)=>{
    response.send('<h1>商品详情页</h1>');
})

// 使用全局中间件路由器  userRouter  goodsRouter
app.use(userRouter,goodsRouter);


app.listen(8080,()=>{
    console.log('server run at 8080');
})